import 'package:flutter/material.dart';

import 'package:heven/api/index.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';

class AgreePage extends StatefulWidget {
  const AgreePage({super.key, this.arguments});
  final arguments;
  @override
  State<AgreePage> createState() => _AgreePageState();
}

class _AgreePageState extends State<AgreePage> {
  String _html = '';
  @override
  void initState() {
    super.initState();
    _init();
  }

  _init() async {
    var result = await getAgree({"code": widget.arguments['type']});

    if (result['status'] == 200) {
      setState(() {
        _html = result['data'];
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.arguments['name']),
      ),
      // body: const WebviewScaffold(
      //   url: 'https://flutter.io',
      // ),
      body: SingleChildScrollView(
        child: HtmlWidget(
          _html,
          //  textStyle: TextStyle(color: Colors.white),
        ),
      ),
    );
  }
}
